/*
 * Copyright 2013 Alibaba.com All right reserved. This software is the
 * confidential and proprietary information of Alibaba.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Alibaba.com.
 */
package com.yunos.tv.common.util;


import org.apache.commons.lang.StringUtils;
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;

/**
 * 类DigestUtil.java的实现描述：TODO 类实现描述
 * @author riqi 2013-7-1 下午5:29:46
 */
public class DigestUtil {

    /**
     * 字符串MD5加密后返回字符串格式，32位
     * @param md5Str
     * @return
     */
    public static String MD5_32(String md5Str) {
        return new Md5PasswordEncoder().encodePassword(md5Str, StringUtils.EMPTY);
    }

    /**
     * 字符串MD5加密后返回字符串格式, 16位
     * @param md5Str
     * @param bit
     * @return
     */
    public static String MD5_16(String md5Str) {
        String md5 = new Md5PasswordEncoder().encodePassword(md5Str, StringUtils.EMPTY);
        return StringUtils.substring(md5, 8, 24);
    }
}
